package com.mayikt.service.aop;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author 余胜军
 * @ClassName ExtThreadAop
 * @qq 644064779
 * @addres www.mayikt.com
 * 微信:yushengjun644
 */
@Aspect
@Component
@Slf4j
public class ExtThreadAsyncAop {


    /**
     * 环绕通知
     * 拦截方法
     *
     * @param joinPoint
     * @return
     */
    @Around(value = "@annotation(com.mayikt.service.annotation.MayiktAsync)")
    public void around(ProceedingJoinPoint joinPoint) {

        log.info(">环绕通知开始执行<");
        new Thread(() -> {
            try {
                joinPoint.proceed();// 目标方法---asyncLog()
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
        }).start();
        log.info(">环绕通知结束执行<");
    }
}
